#pragma once

#include <string_view>
#include <string>
#include <stdexcept>

#include "util/fs.h"

#include "index-item.h"
#include "convert-route.h"
#include "chapter-menu-convert.h"
#include "book-menu-convert.h"
#include "uri-path.h"
#include "index-tree.h"
#include "book.h"


namespace book
{

class BookConvert
{
public:
    class DirCheckError : public std::logic_error
    {
    public:
        DirCheckError(const char *str) : std::logic_error(str) {}
        virtual ~DirCheckError() {}
    };

    BookConvert(const fs::path &srcdir, const fs::path &destdir);

    Book operator()();

private:

    const std::string &title() const {
        return title_;
    }

    void handleDir(const IndexTree::Node *node, const ConvertRoute &route, UriPath &uri);

private:
    const std::string title_;
    const ConvertRoute route_;

    BookMenuConvert bookMenuConvert_;
};

} // namespace book
